package com.sx.admin.controller.plat;

import com.sx.admin.controller.BaseController;
import com.sx.core.model.Order;
import com.sx.core.mybatis.SessionTemplate;
import com.sx.core.page.Page;
import com.sx.core.vo.JsonReaderResponse;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by lihao on 2017/6/29.
 */
@RequestMapping("pl/order")
@RestController
public class OrderController extends BaseController {
    @Autowired
    SessionTemplate sessionTemplate;

    @RequestMapping("list_order")
    public JsonReaderResponse list_order(@RequestBody Map<String,Object> params) {
        int page= NumberUtils.toInt(ObjectUtils.toString(params.get("page")),1);
        int limit= NumberUtils.toInt(ObjectUtils.toString(params.get("limit")),25);
        Page<Order> listPage=sessionTemplate.listPage(Order.class,"listOrder",page,limit,params);
        return new JsonReaderResponse(listPage.getContent(),listPage.getTotalElements());
    }






}
